/*************************************************
Author: will
Date: 2013/03/23
Description:
Notes:
*************************************************/

#ifndef __COssMgr_h__
#define __COssMgr_h__

#include "commclass.h"

class MsgReqOfficeGM;

class COssPlayerTriggerData
{
public:
    unsigned int _uiGID;
    unsigned int _uiTriggerType;    //触发类型
    int _iData1;    //必须保存时间
    int _iData2;
};

class COssMgr
{
public:
    static const int OSS_ZONE_UPDATE_INTERVAL = 15 * 60; //15分钟一次

    COssMgr()
        :_iLastUpdateTime(0) , _iQuarterRegister(0), _iLastNewDayCheck(0), _uiQuarterIncome(0)
    {

    }

    void TimeTick(int iNow);

    //新注册，必须建号的
    void TriggerRegister(unsigned int uiGID);

    //用户发生活跃行为
    void TriggerAct(unsigned int uiGID);

    //用户首充
    void TriggerFirstPay(unsigned int uiGID, int iFee = 0);

    //用户的金币\银币发生变化
    void TriggerMoney(unsigned int uiGID, unsigned char ucOpt, unsigned short usModuleId, int iAmount);

    void TriggerQQPay(unsigned int uiGID, int iQcent, int iGameCoin, int iCertiCoin, const char * pcBillno);

    //跨天结算
    void TriggerNewday(unsigned int uiGID);

    //创建
    void TriggerCreate(CPlayerBaseInfo& stPlayerBaseInfo);

    //登录
    void TriggerLogin(unsigned int uiGID, int iNowTime);

    void TriggerLogin(CPlayerBaseInfo& stPlayerBaseInfo,
            CPlayerDetailInfo& stPlayerDetailInfo);

    //登出
    void TriggerLogout(unsigned int uiGID, int iNowTime);

    //mainsvr停机。 (需要更新今日在线时间)
    void TriggerExit (unsigned int uiGID, int iNowTime);

    //统一用户数据触发接口
    void TriggerPlayer(COssPlayerTriggerData& stData);

    void ClearKeyValueList()
    {
        _astConsume.Clear();
        _astProduce.Clear();
    }
    void AddConsumeItem(CDropItemData& stItem)
    {
        _astConsume.AddOneItem(stItem);
    }
    void AddConsumeItem(unsigned char ucItemType, unsigned short usItemConf,
            int iItemCount, int iData)
    {
        CDropItemData stItem;
        stItem._ucItemType = ucItemType;
        stItem._usItemConfigID = usItemConf;
        stItem._iItemCount = iItemCount;
        stItem._iData1 = iData;
        AddConsumeItem(stItem);
    }
    void AddProduceItem(CDropItemData& stItem)
    {
        _astProduce.AddOneItem(stItem);
    }
    void AddProduceItem(unsigned char ucItemType, unsigned short usItemConf,
            int iItemCount, int iData)
    {
        CDropItemData stItem;
        stItem._ucItemType = ucItemType;
        stItem._usItemConfigID = usItemConf;
        stItem._iItemCount = iItemCount;
        stItem._iData1 = iData;
        AddProduceItem(stItem);
    }

    void TriggerGMSendGift(unsigned int uiGID, MsgReqOfficeGM& stReq);

    void TriggerItem(unsigned int uiGID, int iOptType);

    void UpdateZoneData(int iUpdateTime);

public:
    COssZoneData _stOssZoneData;

private:    
    void PreparePlayerOssInfo(COssPlayerTriggerData& stData);

private:
    int _iLastUpdateTime;
    int _iQuarterRegister;           //15分钟新注册数
    int _iLastNewDayCheck;    //上次跨天统计时间
    unsigned int _uiQuarterIncome;   //15分钟收入

    CTLib::CTArray<CDropItemData, MAX_ITEM_COUNT_PER_USER> _astConsume;//消耗列表
    CTLib::CTArray<CDropItemData, MAX_ITEM_COUNT_PER_USER> _astProduce;//产出列表
};

#endif

